package com.haotunet.app.goldtreasure.adapter;

import java.util.List;
import com.haotunet.app.goldtreasure.R;
import com.haotunet.app.goldtreasure.activity.DepositRecordDetailAct;
import com.haotunet.app.goldtreasure.model.DepositRecord;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class DepositRecordAdapter extends HolderAdapter<DepositRecord, DepositRecordAdapter.ViewHolder> {

	public DepositRecordAdapter(Context context, List<DepositRecord> mlist) {
		super(context, mlist);
	}

	public static class ViewHolder {
		TextView tvMeltGrams;
		TextView tvStoreAddress;
		TextView tvOrderNO;
		TextView mStatus;
		TextView tvDepositTime;
	}

	@Override
	public View buildConvertView(LayoutInflater layoutInflater, DepositRecord t, int position) {
		return inflate(R.layout.item_deposit_record);
	}

	@Override
	public ViewHolder buildHolder(View convertView, DepositRecord t, int position) {
		ViewHolder holder = new ViewHolder();
		holder.tvMeltGrams = (TextView) convertView.findViewById(R.id.txt_melt_quantity);
		holder.tvDepositTime = (TextView) convertView.findViewById(R.id.deposit_time);
		holder.tvOrderNO = (TextView) convertView.findViewById(R.id.deposit_order_no);
		holder.mStatus = (TextView) convertView.findViewById(R.id.txt_status);
		holder.tvStoreAddress = (TextView) convertView.findViewById(R.id.txt_store_address);
		return holder;
	}

	@Override
	public void bindViewDatas(View convertView, ViewHolder holder, DepositRecord depositRecord, int position) {
		holder.tvDepositTime.setText(depositRecord.getCreateTime());
		final String order_no = depositRecord.getOrderNo();
		final String is_accept = depositRecord.getIs_accept();
		holder.tvOrderNO.setText(order_no);
		holder.mStatus.setText(depositRecord.getDepositStatus());
		holder.tvStoreAddress.setText(depositRecord.getShopName());
		holder.tvMeltGrams.setText(depositRecord.getMeltGrams());
		convertView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, DepositRecordDetailAct.class);
				intent.putExtra("order_no", order_no);
				intent.putExtra("is_accept", is_accept);
				context.startActivity(intent);
			}
		});
	}
}
